<template>
	<el-select 
		v-model="value_demo" 
		placeholder="请选择区域"
		@change="selectArea()">
		<el-option
			v-for="item in list_demo"
			:key="item.areaId"
			:label="item.areaName"
			:value="item.areaId">
		</el-option>
	</el-select>
</template>

<script>
export default {
	props:["value"],
	data () {
		return {
			value_demo:"",
			list_demo:[]
		}
	},
	watch:{
		value(){
			this.value_demo = this.value;
		},
	},
	methods:{
		// 获取数据
		list(){
			this.$axios.get('/area/list')
			.then(res=>{
				this.loading = false;
				if(res.code == 200){
					this.list_demo = res.data;
				}
			})
		},
		// 选择下拉框，传值给父级
		selectArea(){
			this.$emit('input',this.value_demo);
		}
	},
	mounted(){
		this.value_demo = this.value;
		this.list();
	}
}
</script>

<style lang="scss" scoped>

</style>